package org.example.controller;

import org.example.pojo.Vip;
import org.example.service.VipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * @author:Cary
 * @date:2023.06.16
 * @version: dev1.8
 * @deion:VIP的控制器
 */
@RestController
@RequestMapping("/admin/vip")
public class VipController {
    @Autowired
    VipService vipService;
    /**
     * 查询全部会员
     * @param: void
     * @return List<Vip>
     */
    @GetMapping("/getvip")
    public List<Vip> findAllVip(){
        return vipService.findallVipList();
    }
    /**
     * 根据id查询会员
     * @param: (Integer id
     * @return Vip
     */
    @GetMapping("/getvip/{id}")
    public Vip findByIdvip(@PathVariable("id") int id){
        return vipService.findByidvip(id);
    }
    /**
     * 根据id删除会员
     * @param: int id
     * @return int
     */
    @PostMapping("/getvip/{id}")
    public int deletevip(@PathVariable("id") int id){
        return vipService.deletevip(id);
    }
    /**
     * 更新会员信息
     * @param: Vip vip
     * @return Vip
     */
    @PostMapping("/update")
    public Vip updateUser (@RequestBody Vip vip){
        System.out.println(vip);
        return vipService.updateVip(vip);
    }
    /**
     * 新增会员
     * @param: Vip vip
     * @return void
     */
    @PostMapping("/addvip")
    public void addvip(@RequestBody Vip vip){
        vipService.addvip(vip);
    }
}
